<%- include('../../common/header.html',{css:'no-common'}) %>

<link rel="stylesheet" href="../../../libs/jcrop/css/jquery.Jcrop.css" type="text/css"/>

<style type="text/css">
    .content {
        padding-top: 30px;
        padding-bottom: 50px;
    }

    /* Apply these styles only when #preview-pane has
       been placed within the Jcrop widget */
    .jcrop-holder #preview-pane {
        display: block;
        position: absolute;
        z-index: 2000;
        top: 10px;
        right: -280px;
        padding: 6px;
        border: 1px #eee solid;
        background-color: white;

        -webkit-border-radius: 2px;
        -moz-border-radius: 2px;
        border-radius: 2px;

        -webkit-box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.2);
        box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.2);
    }

    /* The Javascript code will set the aspect ratio of the crop
       area based on the size of the thumbnail preview,
       specified here */
    #preview-pane .preview-container {
        width: 107px;
        height: 142px;
        overflow: hidden;
    }

    .img-upload {
        width: 450px;
        height: 450px;
        overflow: hidden;
        border: 1px solid #ddd;
        text-align: center;
    }

    .img-upload img {

        max-width: 100%;
        max-height: 100%;
        display: block;;
    }

    .user-thumb-update .upload-tips {
        display: none;
    }

    .user-thumb-update:hover .upload-tips {
        display: block;
    }
</style>
<title>用户管理-后台管理系统</title>
</head>
<body class="sub-body">
<div class="content" style="width: 794px;">
    <div class="panel panel-default">
        <div class="panel-body" style="min-height: 500px;">
            <div class="col-sm-4">
                <form action="#" class="form-horizontal" style="width: 500px;">

                    <div class="form-group">
                        <label class="col-sm-2 control-label">订单合同</label>
                        <div class="col-sm-6">
                            <input type="text" disabled class="form-control"
                                   placeholder="订单合同"
                                   data-rule-required='true'
                                   name='url'>

                            <p style="position: relative;" class="user-thumb-update">
                                <img class="upload-tips"
                                     style="position: relative;display:block;height: 50px;width: 50px;border: 1px solid #e1e1e1;"
                                     src="../../imgs/icon_add_image2.png" alt="">
                                <input type="file" id="file1" name="file" style="display: none;">
                            </p>
                        </div>
                        <div class="col-sm-4">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-10">
                            <button type="submit" hidefocus="true" href="javascript:void(0);"
                                    class="btn submit btn-primary"
                                    data-loading-text="处理中..."
                                    data-rule-required='true'
                                    name='name'>提交
                            </button>
                        </div>
                        <div class="col-sm-4 error-container"></div>
                    </div>
                </form>
            </div>
            <div class="col-sm-8">

            </div>

        </div>
    </div>
</div>
</body>
<%- include('../../common/script-ajax-file-upload.html') %>
<%- include('../../common/script-common.html') %>
<script type="text/javascript">
    var form = null, path = '', img_jcrop = null, searchObj = parseSearch();

    $(function () {

        var fields = "url", $submit = $('.submit');
        var searchObj = parseSearch();
        $(".form-horizontal").validate({
            submitHandler: function (form_) {
                var form = {};
                $submit.button('loading');
                fields.split('|').map(function (item) {
                    form[item] = form_[item].value;
                });
                var form_ = {
                    orderId: searchObj.id,
//                    type:?1,//pdf类型，2，单签合同，3,双签合同
//                    path: form.url,
                };
                if (!form.url) {
                    $submit.button('reset');
                    return alert("请上传合同!");
                }
//                if（）
                if (searchObj.type == 'single') {
                    form_['single'] = form.url;
                } else if (searchObj.type == 'double') {
                    form_['couple'] = form.url;
                } else {
                    form_['path'] = form.url;
                }
                $.post("/order/save-paper", form_, function (xhr, data) {
                    if (xhr.code == 200) {
                        alert('上传成功!');
                        window.close();
                    } else {
                        alert(xhr.error);
                    }
                    $submit.button('reset');
                });
                return false;
            }
        });

        $('.upload-tips').click(function () {
            $(this).siblings('input').click();
        });
        $("#file1").change(function () {
            ajaxFileUpload({
                eleId: 'file1'
            }, function (data) {
                $("[name=url]").val(data.data.path);
            });
        });

    });
</script>

</html>